<?php
$this->headLink()
->appendStylesheet($this->Css('table.css'));
$this->headScript()
->appendFile($this->js('plugins/jquery.blockUI.js'));
?>
<script>
$(document).ajaxStop($.unblockUI);
$(document).ready(function(){
    $(".up-grade").click(function(){
        $("body").block({message:'<h1><?php echo $this->translate('Data setting ..')?></h1>',  border: '3px solid #f00' });
        var id = $(this).attr('id').substr(4);
        $.getJSON('<?php echo $this->route("upgrade")?>',{grade:id}, function(data){
            if (data.result)
            	location.reload();
            else
                alert(data.message);
         });
      });

    $(".redo-up-grade").click(function(){
        if (!confirm('<?php echo $this->translate("current data will be delete ! Are you sure reupgrade?")?>') )
            return false;
        $("body").block({message:'<h1><?php echo $this->translate('Data setting ..')?></h1>',  border: '3px solid #f00' });
        var id = $(this).attr('id').substr(3);
        $.getJSON('<?php echo $this->route("upgrade")?>',{grade:id,redo:1}, function(data){
            if (data.result)
                location.reload();
            else
                alert(data.message);
         });
      });
});
</script>
<style>
.newspaper-a {font-size:100%;margin: 5px auto; white-space: nowrap; text-align:center; width:98%}
.newspaper-a caption {font-size:15px}
</style>

<table border="1" class="newspaper-a">
<thead>
<tr>
<th><?php echo $this->translate('grade')?></th>
<th><?php echo $this->translate('place status')?></th>
<th><?php echo $this->translate('action')?></th>
</tr>
</thead>
<tbody>
<?php foreach($this->ClassGrade() as $grade=>$name) :?>
<tr>
<td><?php echo $name?></td>
<?php if ( ! isset($this->data[$grade])  or  $this->data[$grade] == 0 ):?>
<td><?php echo $this->translate('yet')?></td>
<td><a href="#"  id="sel-<?php echo $grade?>" class="up-grade"><?php echo $this->translate('upgrade reference pervious semester')?></a></td>
<?php else:?>
<td><?php echo $this->translate('finished')?> <?php echo $this->data[$grade]?></td>
<td><a href="#"  id="re-<?php echo $grade?>" class="redo-up-grade"><?php echo $this->translate('redo upgrade reference pervious semester')?></a></td>
<?php endif?>
</tr>
<?php endforeach; ?>
</tbody>
</table>